package com.xxd.spring.boot.demo.zhuhongbing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.zhuhongbing.entity.Teacher;
import com.xxd.spring.boot.demo.zhuhongbing.mapper.TeacherMapper;
import com.xxd.spring.boot.demo.zhuhongbing.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public int add(Teacher teacher) {
        return teacherMapper.insert(teacher);
    }

    @Override
    public int updateById(Teacher teacher) {
        return teacherMapper.updateById(teacher);
    }

    @Override
    public IPage listPage(Page page, Map<String, Object> map) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(map);
        Page resPage=teacherMapper.selectPage(page,queryWrapper);
        return resPage;
    }

    @Override
    public int deleteById(int id) {
        return teacherMapper.deleteById(id);
    }
}
